package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-07-16
 * Time: 9:23
 */
public class Test {
    //输入整型数组下标位置返回下标对应的数字
    public static int getElement(int[] arr,int index) {
        if(arr == null) {
            throw new NullPointerException("空指针异常");
        }
        if(index > arr.length || index < 0) {
            throw new ArrayIndexOutOfBoundsException("数组下标越界异常");
        }
        return arr[index];
    }
    public static void main(String[] args) {
        int[] arr = new int[10];
        System.out.println(getElement(arr,3));
    }
}
